package com.ruibang.glass.equipment.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.equipment.domain.req.AreaReq;
import com.ruibang.glass.equipment.entity.Area;
import com.ruibang.glass.equipment.mapper.AreaMapper;
import com.ruibang.glass.equipment.service.AreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-15  09:17
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {


    /**
     * 获取区域列表
     *
     * @param areaReq
     * @return
     */
    @Override
    public IPage<Area> queryAreas(AreaReq areaReq) {
        return baseMapper.queryAreas(new Page<>(areaReq.getPageNo(), areaReq.getPageSize()), areaReq);
    }

    /**
     * 修改区域
     *
     * @param area
     */
    @Override
    public void updateArea(Area area) {
        this.updateById(area);
    }

    /**
     * @Description: 根据产线获取区域
     * @version v1.0
     * @author songJinKang
     * @date 2023-11-22 15:36
     */
    @Override
    public List<Area> getByProductLineId(String id) {
        return lambdaQuery().eq(Area::getProductLineId, id).list();
    }

    @Override
    public List<Area> getAreaList(String id) {
        return baseMapper.selectList(Wrappers.<Area>lambdaQuery().eq(Area::getProductLineId,id));
    }
    @Override
    public List<Area> getNewAreaList() {
        return baseMapper.selectList(Wrappers.<Area>lambdaQuery());
    }

}
